package com.qf.controller;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Arrays;
import java.util.Random;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/24 16:53
 */
public class Test {
    public static void main(String[] args) {
        Random random = new Random();

        int table = 5;
        int[] val = new int[7];
        for (int i = 0; i < val.length; i++) {
            val[i] = random.nextInt(9) + 1;
        }
        for (int re : val) {
            System.out.print(re + "--");
        }
        System.out.println();
        int[] res = res(table, val);
        for (int re : res) {
            System.out.print(re + "-");
        }
    }

    public static int[] res(int table, int[] num) {
        Arrays.sort(num);
        for (int i : num) {
            System.out.print(i + "  ");
        }
        System.out.println();
        int[] res = new int[table];
        int cur = num.length - 1;
        for (int i = 0; i < table; i++) {
            res[i] = num[cur--];
        }
        int j = table - 1;
        for (int i = cur; i > 0; i--) {
            res[j] += num[i];
            j--;
        }
        return res;
    }

}
